package com.annotation.validator;


public class StringLengthFieldValidator extends FieldValidatorSupport{
	private int maxLength = -1;
    private int minLength = -1;
	public int getMaxLength() {
		return maxLength;
	}
	public void setMaxLength(int maxLength) {
		this.maxLength = maxLength;
	}
	public int getMinLength() {
		return minLength;
	}
	public void setMinLength(int minLength) {
		this.minLength = minLength;
	}
	@Override
	public void validate() {
		String value = getFieldValue();
		int len = value.length();
		if (len < minLength || len > maxLength) {
			this.addErrorCode(this.getFieldName(), this.getMessage());
		}
	}
}
